// created by noellynch
// May 12, 2009

package com.sceneworker.app.globals;

import java.awt.Dimension;
import java.util.Hashtable;

import javax.swing.JDialog;

/**
 * Holds dialog settings in one class so I don't spend half my time grepping.
 * @author noellynch
 *
 */
public final class SceneWorkerDialogManager {
	public static final String WIZARD = "Wizard";
	public static final String TEXTURE_LIST = "Texture List";
	public static final String RESOURCE_LOCATOR_DIALOG = "Resource Locator Dialog";
	public static final String NEW_JAVA_2D_TEXTURE = "New Java 2D Texture";
	public static final String GL_EXTENSIONS_VIEWER = "GL Extensions Viewer";
	public static final String PAINT_TEXTURE = "Paint Texture";
	public static final String TEXTURE_COORDINATE_VIEWER = "Texture Coordinate Viewer";
    public static final String CREATE_LENS_FLARE = "Create Lens Flare";
	public static final String REORGANISE_CHILDREN = "Reorganise Children";
	public static final String NEW_KEY_FRAME = "New Key Frame";
	public static final String BLEND_CALULATOR = "Blend Calulator";
	public static final String MODIFY_RTT_CAMERA = "Modify RTT Camera";
	public static final String HELP = "Help";
	public static final String EDIT_UNIFORM_DIALOG = "EditUniformDialog";
	public static final String NEW_TEXTURE_RENDERER = "New TextureRenderer";
	public static final String BACKGROUND_COLOUR_EDITOR = "Background Colour Editor";
	public static final String SKYBOX_EDITOR_DIALOG = "SkyboxEditorDialog";
	public static final String MATERIAL_EDITOR_DIALOG = "MaterialEditorDialog";
	public static final String EXPORT_TRI_MESH_DIALOG = "ExportTriMeshDialog";
	public static final String COPY_TEXTURE_COORDINATES_DIALOG = "CopyTextureCoordinatesDialog";
	public static final String PROCEDURAL_TEXTURE_GENERATION_DIALOG = "ProceduralTextureGenerationDialog";
	public static final String NEW_CONTROLLER_DIALOG = "NewControllerDialog";
	public static final String NEW_RENDER_STATE_DIALOG = "NewRenderStateDialog";
	public static final String IMPORT_CHILD_DIALOG = "ImportChildDialog";
	public static final String OGRE_IMPORT_DIALOG = "OgreImportDialog";
	public static final String BEAN_SHELL_EDITOR_DIALOG = "BeanShellEditorDialog";
	public static final String SHADER_EXPORT_DIALOG = "ShaderExportDialog";
	public static final String NEW_UNIFORM_VARIABLE_DIALOG = "NewUniformVariableDialog";
	public static final String VERTEXT_PROGRAM_STATE_EDITOR_DIALOG = "VertextProgramStateEditorDialog";
	public static final String TRI_MESH_EDITOR_DIALOG = "TriMeshEditorDialog";
	public static final String TEXTURE_UNITS_EDITOR_DIALOG = "TextureUnitsEditorDialog";
	public static final String CLODTARGET_EDITOR_DIALOG = "CLODTargetEditorDialog";
	public static final String SPATIAL_TRANSFORMER_EDITOR_DIALOG = "SpatialTransformerEditorDialog";
	public static final String GLSLSHADER_EDITOR_DIALOG = "GLSLShaderEditorDialog";
	public static final String FRAGMENT_PROGRAM_STATE_EDITOR_DIALOG = "FragmentProgramStateEditorDialog";
	public static final String DISTANCE_MODEL_EDITOR_DIALOG = "DistanceModelEditorDialog";
	public static final String PREFERENCES_DIALOG = "PreferencesDialog";
	public static final String ROTATOR_DIALOG = "RotatorDialog";
	
	static	private		SceneWorkerDialogManager		mcl_inst;
	
	static	public	SceneWorkerDialogManager		inst() {
		if(mcl_inst == null) {
			mcl_inst = new SceneWorkerDialogManager();
		}
		
		return mcl_inst;
	}
	
	private		Hashtable<String, DialogSettings>		mcla_dlgSettings;
	
	private		SceneWorkerDialogManager() {
		mcla_dlgSettings = new Hashtable<String, DialogSettings>();
		
		mcla_dlgSettings.put(ROTATOR_DIALOG, new DialogSettings(400, 200, "Rotator"));
		mcla_dlgSettings.put(RESOURCE_LOCATOR_DIALOG, new DialogSettings(400, 250, RESOURCE_LOCATOR_DIALOG));
		mcla_dlgSettings.put(PREFERENCES_DIALOG, new DialogSettings(550, 400, "Preferences", true));
		mcla_dlgSettings.put(NEW_UNIFORM_VARIABLE_DIALOG, new DialogSettings(300, 150, "New Uniform Variable"));
		mcla_dlgSettings.put(EDIT_UNIFORM_DIALOG, new DialogSettings(300, 150, "Edit Uniform Dialog"));
		mcla_dlgSettings.put(SHADER_EXPORT_DIALOG, new DialogSettings(400, 300, "Export Shaders"));
		mcla_dlgSettings.put(BEAN_SHELL_EDITOR_DIALOG, new DialogSettings(450, 500, "Bean Shell Editor", true));
		mcla_dlgSettings.put(DISTANCE_MODEL_EDITOR_DIALOG, new DialogSettings(450, 500, "Distance Model Editor"));
		mcla_dlgSettings.put(FRAGMENT_PROGRAM_STATE_EDITOR_DIALOG, new DialogSettings(450, 500, "Fragment Program Editor"));
		mcla_dlgSettings.put(VERTEXT_PROGRAM_STATE_EDITOR_DIALOG, new DialogSettings(450, 500, "Vertex Program Editor"));
		mcla_dlgSettings.put(GLSLSHADER_EDITOR_DIALOG, new DialogSettings(700, 570, "GLSL Shader Editor", true));
		mcla_dlgSettings.put(SPATIAL_TRANSFORMER_EDITOR_DIALOG, new DialogSettings(450, 300, "Spatial Transformer Editor", true));
		mcla_dlgSettings.put(CLODTARGET_EDITOR_DIALOG, new DialogSettings(450, 500, "CLOD Target Editor"));
		mcla_dlgSettings.put(TEXTURE_UNITS_EDITOR_DIALOG, new DialogSettings(435, 525, "Texture Units Editor", true));
		mcla_dlgSettings.put(TRI_MESH_EDITOR_DIALOG, new DialogSettings(450, 500, "Tri Mesh Editor"));
		mcla_dlgSettings.put(OGRE_IMPORT_DIALOG, new DialogSettings(300, 200, "Ogre Importer", true));
		mcla_dlgSettings.put(IMPORT_CHILD_DIALOG, new DialogSettings(400, 300, "Import Child"));
		mcla_dlgSettings.put(NEW_RENDER_STATE_DIALOG, new DialogSettings(300, 150, "New RenderState"));
		mcla_dlgSettings.put(NEW_CONTROLLER_DIALOG, new DialogSettings(300, 150, "New Controller"));
		mcla_dlgSettings.put(PROCEDURAL_TEXTURE_GENERATION_DIALOG, new DialogSettings(500, 500, "Procedural Texture Generator", true));
		mcla_dlgSettings.put(COPY_TEXTURE_COORDINATES_DIALOG, new DialogSettings(300, 150, "Copy Texture Coordinates"));
		mcla_dlgSettings.put(EXPORT_TRI_MESH_DIALOG, new DialogSettings(300, 200, "Export TriMesh"));
		mcla_dlgSettings.put(MATERIAL_EDITOR_DIALOG, new DialogSettings(400, 350, "Material Editor", true));
		mcla_dlgSettings.put(SKYBOX_EDITOR_DIALOG, new DialogSettings(600, 680, "Sky Box Editor"));
		mcla_dlgSettings.put(BACKGROUND_COLOUR_EDITOR, new DialogSettings(300, 200, BACKGROUND_COLOUR_EDITOR, true));
		mcla_dlgSettings.put(NEW_TEXTURE_RENDERER, new DialogSettings(400, 140, NEW_TEXTURE_RENDERER));
		mcla_dlgSettings.put(NEW_JAVA_2D_TEXTURE, new DialogSettings(400, 400, NEW_JAVA_2D_TEXTURE, true));
		mcla_dlgSettings.put(HELP, new DialogSettings(500, 440, HELP, true, false));
		mcla_dlgSettings.put(MODIFY_RTT_CAMERA, new DialogSettings(300, 200, MODIFY_RTT_CAMERA, true));
		mcla_dlgSettings.put(PAINT_TEXTURE, new DialogSettings(300, 300, PAINT_TEXTURE, true));
		mcla_dlgSettings.put(BLEND_CALULATOR, new DialogSettings(300, 200, BLEND_CALULATOR, true, false));
		mcla_dlgSettings.put(NEW_KEY_FRAME, new DialogSettings(200, 100, NEW_KEY_FRAME));
		mcla_dlgSettings.put(REORGANISE_CHILDREN, new DialogSettings(300, 300, REORGANISE_CHILDREN, true));
		mcla_dlgSettings.put(CREATE_LENS_FLARE, new DialogSettings(400, 220, CREATE_LENS_FLARE, true));
		mcla_dlgSettings.put(TEXTURE_COORDINATE_VIEWER, new DialogSettings(400, 320, TEXTURE_COORDINATE_VIEWER, true, false));
		mcla_dlgSettings.put(GL_EXTENSIONS_VIEWER, new DialogSettings(300, 420, GL_EXTENSIONS_VIEWER, true, false));
		mcla_dlgSettings.put(TEXTURE_LIST, new DialogSettings(400, 600, TEXTURE_LIST, true, false));
		mcla_dlgSettings.put(WIZARD, new DialogSettings(400, 400, WIZARD, true));
		
	}
	
	public	JDialog		makeADialog(String str_dialogKey) {
		return this.makeADialog(str_dialogKey, null);
	}
	
	public	JDialog		makeADialog(String str_dialogKey, JDialog cl_par) {
		DialogSettings		lcl_settings = null;
		
		try {
			lcl_settings = mcla_dlgSettings.get(str_dialogKey);
		} catch (Exception e) {
			
		}
		
		JDialog				lcl_dlg;
		
		if(cl_par != null) {
			lcl_dlg = new JDialog(cl_par);
		} else {
			lcl_dlg = new JDialog();
		}
		
		if(lcl_settings == null) {
			lcl_dlg.setSize(400, 300);
			lcl_dlg.setModal(true);
		} else {
			lcl_dlg.setSize(lcl_settings.mi_width, lcl_settings.mi_height);
			lcl_dlg.setTitle(lcl_settings.mstr_title);
			lcl_dlg.setModal(lcl_settings.mb_modal);
			lcl_dlg.setResizable(lcl_settings.mb_resizable);
		}
		
		lcl_dlg.setLocationRelativeTo(null);
		return lcl_dlg;
	}
	
	class	DialogSettings {
		public	int				mi_width;
		public	int				mi_height;
		public	String			mstr_title;
		public	boolean			mb_resizable;
		public	boolean			mb_modal;
		
		public	DialogSettings(int i_w, int i_h, String str_title) {
			this(i_w, i_h, str_title, false, true);
			
		}
		
		public	DialogSettings(int i_w, int i_h, String str_title, boolean b_resizable) {
			this(i_w, i_h, str_title, b_resizable, true);
		}
		
		public	DialogSettings(int i_w, int i_h, String str_title, boolean b_resizable, boolean b_modal) {
			mi_width = i_w;
			mi_height = i_h;
			mstr_title = str_title;
			mb_resizable = b_resizable;
			mb_modal = b_modal;
		}
	}
}
